package com.wd.tech.base;

import com.wd.tech.bean.CancelCommunityGreatBean;
import com.wd.tech.contract.IContract;

import java.lang.ref.WeakReference;

/**
 * 时间：2020/7/1
 * 作者：徐黎明
 * 类的作用：
 */
public abstract class BasePresenter <V extends IContract.IView>  implements IContract.IPresenter {
    //弱应用
    protected WeakReference<V> weakReference;
   public BasePresenter(){
       initModel();
    }
    //绑定
    protected void attach(V v){
       weakReference=new WeakReference<>(v);
    }
    //解绑
    protected void  deatch(){
        if (weakReference != null) {
            weakReference.clear();
            weakReference=null;
        }
    }
    //获取view的视图
    public V getView(){
       return weakReference.get();
    }
    protected abstract void initModel();

}
